'use strict';

module.exports = app => {
    const { Sequelize, model } = app

    const Model = model.define('bookconfig', {
        id:{
            type: Sequelize.STRING.BINARY,
            defaultValue: Sequelize.UUIDV1,
            primaryKey: true
        },
        t0900:{
            type: Sequelize.INTEGER(3),
            defaultValue: 0,
            allowNull: false
        },
        t1000:{
            type: Sequelize.INTEGER(3),
            defaultValue: 0,
            allowNull: false
        },
        t1100:{
            type: Sequelize.INTEGER(3),
            defaultValue: 0,
            allowNull: false
        },
        t1130:{
            type: Sequelize.INTEGER(3),
            defaultValue: 0,
            allowNull: false
        },
        t1400:{
            type: Sequelize.INTEGER(3),
            defaultValue: 0,
            allowNull: false
        },
        t1500:{
            type: Sequelize.INTEGER(3),
            defaultValue: 0,
            allowNull: false
        },
        t1600:{
            type: Sequelize.INTEGER(3),
            defaultValue: 0,
            allowNull: false
        },
        t1700:{
            type: Sequelize.INTEGER(3),
            defaultValue: 0,
            allowNull: false
        },
        filter: {
            type: Sequelize.JSON
        }
    }, {
        freezeTableName: true,
        tableName: 'tb_bookconfig',
        timestamps: true,
        paranoid: true,
    })

    Model.associate = function() {
        model.Bookconfig.belongsTo(model.Corp)
        model.Corp.hasOne(model.Bookconfig)
    }

    return Model
}